import axios from "axios";

// axios 接受两个泛型变量 T D
//    T 用于描述接口返回值的类型
//    D AxiosResponse<T>
//    <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
axios<{ code: string; data: string[] }>({
  url: "http://localhost:3001/admin/admin/login",
  method: "POST",
  data: {
    adminname: "admin",
    password: "123456",
  },
}).then((res) => {
  res.data.code;
});

axios<any, { name: string; age: number }>({
  url: "http://localhost:3001/admin/admin/login",
  method: "POST",
  data: {
    adminname: "admin",
    password: "123456",
  },
}).then((res) => {
  res.name;
  res.age;
});
